<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="100">
			<row>
				<Col span="8" class="title">
				<FormItem class="w-100" label="标题">
					<Input type="text" v-model="carRent.title" style="width: 500px;"/>
				</FormItem>
				<FormItem class="w-100" label="发布者">
					<Input type="text" v-model="carRent.personName" style="width: 500px;"/>
				</FormItem>
				</FormItem>
				<FormItem class="w-100" label="联系方式">
					<Input type="text" v-model="carRent.tel" style="width: 500px;"/>
				</FormItem>
				<FormItem class="w-100" label="联系微信">
					<Input type="text" v-model="carRent.wxNumber" style="width: 500px;"/>
				</FormItem>
				<FormItem class="w-100" label="描述">
					<Input type="textarea" :rows="6" v-model="carRent.details" style="width: 500px; height: 150px;"/>
				</FormItem>
				
				<FormItem>
					<Button @click="submit" type="primary">修改</Button>
					<Button @click="cancel" style="margin-left: 8px">取消</Button>
				</FormItem>
				</Col>
			</row>
		</Form>

	</Layout>
</template>

<script>
	export default {
		data: function() {
			return {
				crId: 0,
				carRent: {},
				carRentInfo:{
					crId : 0,
					title:"",
					tel:'',
					wxNumber:'',
					personName:'',
					details:""
				}

			};
		},
		methods: {
			cancel: function() {
				this.$tabs.close();
			},
			submit: function() {
				let self = this;
				if (this.$data.carRent.title.length == 0) {
					this.message.error("标题必须输入");
					return;
				}
				console.log(self.$data.carRent.details)
				self.$data.carRentInfo.crId = self.$data.carRent.crId
				self.$data.carRentInfo.title = self.$data.carRent.title
				self.$data.carRentInfo.details = self.$data.carRent.details
				self.$data.carRentInfo.personName = self.$data.carRent.personName
				self.$data.carRentInfo.tel = self.$data.carRent.tel
				self.$data.carRentInfo.wxNumber = self.$data.carRent.wxNumber
				console.log(self.$data.carRentInfo.details)
				this.http.put({
					
					url: "/car-rent-info/info",
					param : self.carRentInfo
				}).then(() => {
					self.message.info("修改成功");
					self.$tabs.close();
                    this.$router.push(
                    {
                        name:"carRent"
                        
                    })
				});
			},
			init: function() {


				let self = this;

				self.http.get({
					url: "/car-rent-info/info",
					param: {
						crId: self.$data.crId
					}
				}).then(data => {

					self.$data.carRent = data;
				});



			}
		},
		created: function() {
			console.log(this.$route.params.crId)
			this.$data.crId = this.$route.params.crId;
			this.init();
		},
	}
</script>

<style>
</style>
